﻿using UnityEngine;
using System.Collections;
using UnityEditor;

namespace Hont.HyperWigglePackage.Editor
{
    public abstract class BaseWigglePlugins : IHyperWigglePlugin
    {
        protected HyperWiggleEditorCore mCore;
        public GUIContent Name { get { return new GUIContent(GetType().Name); } }


        public BaseWigglePlugins()
        {
        }

        public virtual void Execute(HyperWiggleEditorCore core)
        {
            mCore = core;

            var window = EditorWindow.GetWindow<HyperWiggleEmptyWindow>();
            window.OnGUIRefreshCB = OnGUI;
            window.OnExitCB = OnExit;
            window.titleContent = Name;

            mCore.OnDestroyCB += () =>
            {
                window.Close();
            };
        }

        protected abstract void OnExit();

        protected abstract void OnGUI();
    }
}
